package model.core.torneo;

import model.core.utente.Commissario;
import model.core.utente.AbstractDomainModelObservable;
import model.utility.Constants;
import model.utility.Utility;

import java.util.ArrayList;

/**
 * 
 * @author Giuseppe Fusco (fusgius19@gmail.com)
 *
 */
public class Commissione extends AbstractDomainModelObservable {

	private ArrayList<Commissario> commissione;

	public Commissione(){
		commissione = new ArrayList<Commissario>();
	}
	
	public boolean addCommissario(Commissario commissario) {
		return (
				!Utility.isThereCommissario(commissione, commissario) &&
				commissione.size()<Constants.max_commissari)?
						commissione.add(commissario):
							false;
	}

	public boolean removeCommissario(Commissario commissario) {
		return (
				Utility.isThereCommissario(commissione, commissario) && 
				commissione.size()>Constants.min_commissari)?
						commissione.remove(commissario):
							false;
	}

	public ArrayList<Commissario> getCommissione() {
		return commissione;
	}

	public boolean setCommissione(ArrayList<Commissario> commissione) {
		if(commissione.size()<=Constants.max_commissari && commissione.size()>=Constants.min_commissari){
			this.commissione = commissione;
			return true;
		}else
			return false;
	}

}
